package org.elanfox.intellicommunity.data.base.vo;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author wm
 */
@Getter
@Setter
public class PageDataVO<T> {
    /**
     * 页面大小
     */
    public int pageSize;
    /**
     * 当前页码
     */
    public int pageIndex;
    /**
     * 总记录数
     */
    public long total;
    /**
     * 页面数
     */
    public int pageCount;
    /**
     * 数据行对象
     */
    public List<T> rows;

    public int calculatePageCount() {
        if (this.pageSize == 0) {
            return 0;
        }
        return (int) this.total / this.pageSize + (this.total % this.pageSize == 0 ? 0 : 1);
    }
}